package com.py.androidUtils.UI;

import java.util.ArrayList;
import java.util.List;

import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.CheckBox;
import android.widget.TextView;

import com.py.androidUtils.UI.adapter.GroupUserAdapter;
import com.py.androidUtils.UI.model.UserInfoView;
import com.py.androidUtils.UI.view.ShowEmptyChatRecordView;
import com.py.androidUtils.UI.view.ShowEmptyChatRecordView.EmptyChatClickListener;
import com.py.androidUtils.base.BaseActivity;
import com.py.androidUtils.utils.ToastUtil;
import com.py.androidUtils.view.NoScrollGridView;
import com.readyidu.app.R;

public class ChatDetailsActivity extends BaseActivity implements OnClickListener {
	private NoScrollGridView gridView;
	private GroupUserAdapter groupUserAdapter;
	private CheckBox topChat;
	private CheckBox messageDisturb;
	private TextView remark;
	private TextView emptyChatRecord;
	private TextView report;

	@Override
	protected void onCreate(Bundle arg0) {
		super.onCreate(arg0);
		setContentView(R.layout.activity_chat_details);

		getTitleActionBar().setTitleBar("聊天详情");
		getTitleActionBar().setImgLeft(R.drawable.icon_back, new OnClickListener() {
			@Override
			public void onClick(View v) {
				finishactivity(ChatDetailsActivity.this);
			}
		});

		gridView = (NoScrollGridView) this.findViewById(R.id.gridView);
		groupUserAdapter = new GroupUserAdapter(ChatDetailsActivity.this);
		gridView.setAdapter(groupUserAdapter);

		topChat = (CheckBox) this.findViewById(R.id.topChat);
		messageDisturb = (CheckBox) this.findViewById(R.id.messageDisturb);
		remark = (TextView) this.findViewById(R.id.remark);
		emptyChatRecord = (TextView) this.findViewById(R.id.emptyChatRecord);
		report = (TextView) this.findViewById(R.id.report);

		List<UserInfoView> list = new ArrayList<UserInfoView>();
		UserInfoView infoView = new UserInfoView();
		infoView.setImg("http://img5.imgtn.bdimg.com/it/u=3638412718,2736228005&fm=21&gp=0.jpg");
		infoView.setName("测试a");
		infoView.setType(0);
		list.add(infoView);

		UserInfoView infoView1 = new UserInfoView();
		infoView1.setType(1);
		list.add(infoView1);

		groupUserAdapter.setList(list);

		remark.setOnClickListener(this);
		emptyChatRecord.setOnClickListener(this);
		report.setOnClickListener(this);
	}

	@Override
	public void onClick(View v) {
		switch (v.getId()) {
		case R.id.remark:
			ToastUtil.showToast(getApplicationContext(), "备注");
			launcherActivity(ChatDetailsActivity.this, RemarkActivity.class, null);
			break;
		case R.id.emptyChatRecord:
			ShowEmptyChatRecordView chatRecordView = new ShowEmptyChatRecordView(ChatDetailsActivity.this);
			chatRecordView.showView(emptyChatRecord);
			chatRecordView.setEmptyChatClickListener(new EmptyChatClickListener() {
				@Override
				public void emptyChat() {
					ToastUtil.showToast(getApplicationContext(), "清空消息记录");
				}
			});
			break;
		case R.id.report:
			ToastUtil.showToast(getApplicationContext(), "举报");
			launcherActivity(ChatDetailsActivity.this, ReportActivity.class, null);
			break;
		}
	}
}
